//
//  TodayHotTableViewCell.m
//  CapriceMusic
//
//  Created by dllo on 16/1/9.
//  Copyright © 2016年 MYX. All rights reserved.
//

#import "TodayHotTableViewCell.h"

@implementation TodayHotTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.coverPic = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.coverPic.contentMode = UIViewContentModeCenter;
        self.coverPic.clipsToBounds = YES;
        [self addSubview:self.coverPic];
        
        self.headView = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.headView.layer.cornerRadius = 25;
        self.headView.layer.masksToBounds = YES;
        [self addSubview:self.headView];
        
        self.addView = [[UIImageView alloc] initWithFrame:CGRectZero];
        [self addSubview:self.addView];
        
        self.nameLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        self.nameLabel.textColor = [UIColor colorWithRed:0 green:139/255.0 blue:69/255.0 alpha:1];
        self.nameLabel.font = [UIFont systemFontOfSize:10];
        [self addSubview:self.nameLabel];
        
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        self.titleLabel.font = [UIFont systemFontOfSize:11];
        self.titleLabel.textColor = [UIColor whiteColor];
        [self addSubview:self.titleLabel];
        
        self.numLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        self.numLabel.textColor = [UIColor whiteColor];
        self.numLabel.font = [UIFont systemFontOfSize:8];
        [self addSubview:self.numLabel];
    }
    return self;
}

- (void)setTodayHotModel:(TodayHotModel *)todayHotModel {
    if (_todayHotModel != todayHotModel) {
        _todayHotModel = todayHotModel;
    }
    [self.coverPic sd_setImageWithURL:[NSURL URLWithString:_todayHotModel.playListBigPic]];
    
    [self.headView sd_setImageWithURL:[NSURL URLWithString:_todayHotModel.creator[@"largeAvatar"]]];
    self.titleLabel.text = _todayHotModel.title;
    self.nameLabel.text = _todayHotModel.creator[@"nickName"];
    NSString *str = @"播放次数:";
    self.numLabel.text = [str stringByAppendingString:_todayHotModel.totalViews.description];
}


- (void)layoutSubviews {
    [super layoutSubviews];
    self.coverPic.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
    self.addView.frame = self.bounds;
    self.headView.frame = CGRectMake(self.frame.size.width / 20, self.frame.size.height * 0.65, 50, 50);
    self.titleLabel.frame = CGRectMake(self.frame.size.width / 4, self.frame.size.height * 0.65, self.frame.size.width / 2, 20);
    self.nameLabel.frame = CGRectMake(self.frame.size.width / 4, self.frame.size.height * 0.75, self.frame.size.width / 4, 20);
    self.numLabel.frame = CGRectMake(self.frame.size.width / 4, self.frame.size.height * 0.85, self.frame.size.width / 4, 20);
}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
